<%--
  Created by IntelliJ IDEA.
  User: starrysky
  Date: 2021/2/6
  Time: 17:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>login</title>
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <script>
        function a1(){
            $.post({
                url:"${pageContext.request.contextPath}/a2",
                // 巨坑就是data的{}问题需要注意
                data:{"username":$("#username").val()},
                success:function (data){
                    console.log(data);
                    if (data=="ok"){
                        $("#nameInfo").css("color","green");
                    }else {
                        $("#nameInfo").css("color","red");
                    }
                    $("#nameInfo").html(data);
                }
            });
        }

        function a2(){
            $.post({
                url:"${pageContext.request.contextPath}/a2",
                // 巨坑就是data的{}问题需要注意
                data:{"password":$("#password").val()},
                    success:function (data){
                        console.log(data);
                        if (data=="ok"){
                            $("#pwdInfo").css("color","green");
                        }else {
                            $("#pwdInfo").css("color","red");
                        }
                        $("#pwdInfo").html(data);
                    }
            });
        }

    </script>
</head>
<body>
<p>
    用户名：<input type="text" id="username" onblur="a1()">
    <span id="nameInfo"></span>
</p>
<p>
    用户密码：<input type="password" id="password" onblur="a2()">
    <span id="pwdInfo"></span>
</p>
</body>
</html>
